﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.ComponentModel.DataAnnotations;
using System.Web.Mvc;
using System.ComponentModel;

namespace RedSand.Site.Models
{
    public class UserInfo
    {
        [Key]
        [HiddenInput(DisplayValue = false)]
        public int UserID { get; set; }

        [Display(Name = "Username")]
        [Required]
        public string Username { get; set; }

        [Display(Name = "Fullname")]
        [Required]
        public string Fullname { get; set; }

        [Display(Name = "Password")]
        [Required]
        [DataType(DataType.Password)]
        [StringLength(50, MinimumLength = 5)]
        public string Password { get; set; }

        [Display(Name = "Email")]
        [DataType(DataType.EmailAddress)]
        [RegularExpression(@"^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$")]
        [Required]
        public string Email { get; set; }

        [Display(Name = "JoinDate")]
        [DataType(DataType.Date)]
        [DisplayFormat(DataFormatString = "{0:dd/MM/yyyy}")]
        public DateTime? JoinDate { get; set; }

        [Display(Name = "Birthday")]
        [DataType(DataType.Date)]
        [DisplayFormat(DataFormatString = "{0:dd/MM/yyyy}")]
        public DateTime? Birthday { get; set; }

        [Display(Name = "Phone")]
        [DataType(DataType.PhoneNumber)]
        public string Phone { get; set; }

        [Display(Name = "Avatar")]
        public string Avatar { get; set; }

        [Display(Name = "Address")]
        public string Address { get; set; }

        [Display(Name = "Rank")]
        public int? Rank { get; set; }

        [Display(Name = "IsAdmin")]
        public bool? IsAdmin { get; set; }

        [Display(Name = "Status")]
        public byte? Status { get; set; }
    }
    public class LoginModel
    {
        [Required]
        [Display(Name = "Username")]
        public string Username { get; set; }

        [Required]
        [DataType(DataType.Password)]
        [Display(Name = "Password")]
        public string Password { get; set; }

        [Display(Name = "RememberMe")]
        public bool RememberMe { get; set; }
    }
    public class ChangePasswordModel
    {
        [Required]
        [DataType(DataType.Password)]
        [Display(Name = "OldPassword")]
        public string OldPassword { get; set; }

        [Required]
        [DataType(DataType.Password)]
        [Display(Name = "NewPassword")]
        public string NewPassword { get; set; }

        [DataType(DataType.Password)]
        [Required]
        [Display(Name = "ConfirmPassword")]
        [Compare("NewPassword", ErrorMessage = "Confirm Password not match")]
        public string ConfirmPassword { get; set; }
    }
    public class ResetPasswordModel
    {
        [Display(Name = "Username")]
        [Required]
        public string Username { get; set; }

        [Required]
        [DataType(DataType.Password)]
        [Display(Name = "OldPassword")]
        public string OldPassword { get; set; }

        [Required]
        [DataType(DataType.Password)]
        [Display(Name = "NewPassword")]
        public string NewPassword { get; set; }

        [DataType(DataType.Password)]
        [Display(Name = "ConfirmPassword")]
        [Compare("NewPassword", ErrorMessage = "Confirm Password not match")]
        public string ConfirmPassword { get; set; }
    }

    public class LostPasswordModel
    {
        [Required]
        [Display(Name = "Username")]
        public string Username { get; set; }

        [Required]
        [Display(Name = "Email")]
        public string Email { get; set; }
    }
    public class SearchUsersModel
    {
        public string Keyword { get; set; }
        public string RoleID { get; set; }
        public byte? Status { get; set; }
    }
    public class CreateUserModel : UserInfo
    {
        [DataType(DataType.Password)]
        [Display(Name = "ConfirmPassword")]
        [Compare("Password", ErrorMessage = "Confirm Password not match")]
        [Required]
        public string ConfirmPassword { get; set; }

    }
    public class UserInfoTiny
    {
        [Key]
        [HiddenInput(DisplayValue = false)]
        public int UserID { get; set; }

        [Display(Name = "Username")]
        public string Username { get; set; }

        [Display(Name = "Fullname")]
        [Required]
        public string Fullname { get; set; }
      
        [Display(Name = "Password")]
        [Required]
        [DataType(DataType.Password)]
        [StringLength(50, MinimumLength = 6)]
        public string Password { get; set; }

        [Display(Name = "Email")]
        [DataType(DataType.EmailAddress)]
        [RegularExpression(@"^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$")]
        [Required]
        public string Email { get; set; }

        [Display(Name = "JoinDate")]
        [DataType(DataType.Date)]
        public DateTime? JoinDate { get; set; }

        [Display(Name = "Status")]
        public byte? Status { get; set; }

        
    }

    public class CreateUserFrontEndModel : UserInfoTiny
    {

        [Display(Name = "Captcha")]
        [Required]
        public string captcha { get; set; }

        [DataType(DataType.Password)]
        [Display(Name = "ConfirmPassword")]
        [Compare("Password", ErrorMessage = "Confirm Password not match")]
        [Required]
        public string ConfirmPassword { get; set; }

    }
}